package SpaceIT.pages;

import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.Response;
import org.apache.tapestry5.services.Session;

import model.dao.PaypalDAO;
import model.pojo.Paypal;
import model.util.paypalfunctions;

public class review {
	@Inject
	private Request request;
	@Inject
	private Response response;
	
	public Object onActivate()
	{
		java.util.HashMap nvp = null;
        //HttpSession session = request.getSession();
        Session session = request.getSession(true);
		String token = session.getAttribute("TOKEN").toString();
		if ( token != null)
		{
		
		//IMPORTANT NOTE: Please import Class paypalfunctions if not in the same package level.
		// import paypalfunctions;
		
			/*
			'------------------------------------
			' Calls the GetExpressCheckoutDetails API call
			'
			' The GetShippingDetails function is defined in PayPalFunctions.jsp
			' included at the top of this file.
			'-------------------------------------------------
			*/
			
			//String token = (String) session.getAttribute("token");
			Paypal pp = PaypalDAO.LayThongTinPaypal();
			paypalfunctions ppf = new paypalfunctions(pp);
			nvp = ppf.GetShippingDetails( token );
			System.out.println("nvp" + nvp);
			if (nvp == null)
	        {            
				return null;
	        }
			session.setAttribute("PAYERID", nvp.get("PAYERID").toString());
			return confirm.class;
		}
		return null;
	}	
	

}
